package com.springboot.learning.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.learning.result.BaseResponseInfo;
import com.springboot.learning.service.UserService;

@RestController
@RequestMapping("/user")
public class UserController {

	 @Autowired
	    private UserService userService;
 
	    /**
	     * 查询单个用户
	     */
	    @RequestMapping(value = "/{id}",method={ RequestMethod.GET })
	    public BaseResponseInfo findUserById(@PathVariable("id") Integer id) throws Exception {
	    	BaseResponseInfo info = new BaseResponseInfo();
	    	//List<User> list =userService.selectList(new EntityWrapper().where("id = {0}", id));
	    	info.data=userService.selectUserById(id);
	        return info;
	    }

	    /**
	     * 查询单个用户
	     */
	    @RequestMapping(value = "/account",method={ RequestMethod.POST })
	    public BaseResponseInfo findUserByAccout(@RequestParam("account") String account) throws Exception {
	    	BaseResponseInfo info = new BaseResponseInfo();
	    	//List<User> list =userService.selectList(new EntityWrapper().where("account = {0}", account));
	    	info.data=userService.selectUserByAccout(account);
	        return info;
	    }

}
